<?php
include_once '../settings.php'; 
include_once APPROOT.'inc/simpleconfig.php';
include_once APPROOT.'admin/collectnews.php';

$dbutil = new DButil();


$flag = $_GET['flag'];

if($flag){
//	$host = $_SERVER['HTTP_HOST'];
//	echo $host;
	$fp = fsockopen("127.0.0.1", 80, $errno, $errorstr);
	fputs($fp, "GET /admin/admin_collect_collecting.php\r\n\r\n");
	fclose($fp);
	echo "1";
	exit();
}

$query = "select count(*) from news_keyword";
$result = $dbutil->exequery($query);
$row = $dbutil->fetch_array($result);
$count = $row[0];
$sql = "select keyword,is_collection,modified as created from news_keyword order by created limit $start, $limit";
$result = $dbutil->exequery($sql);

$nodes = array() ;
	while ($row = $dbutil->fetch_array( $result)){
		$node = array();
		foreach($row as $key => $value){
			$node[$key] = $value ;
	    }
	$nodes[] = $node ;
   }
		
		
echo "{success: true, coders:".json_encode($nodes).",count:".$count."}" ;